import os
import argparse

img_path = "./jpg"
png_path = './png'


def jpg_2_png():
    for root, ds, fs in os.walk(img_path):
        for f in fs:
            png_name = png_path + "/" + f.split('.')[0] + ".png"
            img_name = img_path + "/" + f
            os.rename(img_name, png_name)
            
            
def png_2_jpg():
    for root, ds, fs in os.walk(png_path):
        for f in fs:
            png_name = png_path + "/" + f
            img_name = img_path + "/" + f.split('.')[0] + ".jpg"
            os.rename(png_name, img_name)
            
if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument("-jpg", help="jpg convert to png.", action="store_true")
    parser.add_argument("-png", help="png convert to jpg.", action="store_true")
    args = parser.parse_args()
    if args.jpg:
        jpg_2_png()
    elif args.png:
        png_2_jpg()